package uns.fit.gis.contextmenu;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Displayable;

import uns.fit.gis.MapDrawer;
import uns.fit.gis.i18n.LocaleManager;
import uns.fit.gis.mapdrawer.ActionCode;

public class GlobalContextMenu extends ContextMenu {
	public GlobalContextMenu() {
		commands = new Command[10];
		commands[0] = new Command(LocaleManager.getMessage("exit"), Command.EXIT, 1);
		commands[1] = new Command(LocaleManager.getMessage("menu"), Command.ITEM, 1);
		commands[2] = new Command(LocaleManager.getMessage("layerlist"), Command.ITEM, 1);
		commands[3] = new Command(LocaleManager.getMessage("viewtracklogs"), Command.ITEM, 1);
		commands[4] = new Command(LocaleManager.getMessage("saveuserlocation"), Command.ITEM, 1);
		commands[5] = new Command(LocaleManager.getMessage("viewuserlocations"), Command.ITEM, 1);
                commands[6] = new Command("Connect CellService", Command.ITEM, 1);
                commands[7] = new Command("Stop CellService", Command.ITEM, 1);
                commands[8] = new Command("Info CellService", Command.ITEM, 1);
                commands[9] = new Command(LocaleManager.getMessage("help"), Command.ITEM, 1);
	}
	public void commandAction(Command command, Displayable displayable) {
		if(command == commands[0]) {
			MapDrawer.getMidlet().mapCanvas.commandAction(ActionCode.DESTROY_APP);
		}
		else if(command == commands[1]) {
			MapDrawer.getMidlet().mapCanvas.commandAction(ActionCode.SHOW_MENU);
		}
		else if(command == commands[2]) {
			MapDrawer.getMidlet().mapCanvas.commandAction(ActionCode.SHOW_LAYER_LIST);
		}
		else if(command == commands[3]) {
			MapDrawer.getMidlet().mapCanvas.commandAction(ActionCode.SHOW_TRACKLOG_FORM);
		}
		else if(command == commands[4]) {
			MapDrawer.getMidlet().showSaveCurPosForm();
		}
		else if(command == commands[5]) {
			MapDrawer.getMidlet().showUserLocationList();
		}
		else if(command == commands[9]) {
			MapDrawer.getMidlet().showHelpForm();
		}
                else if(command == commands[6]) {
			MapDrawer.getMidlet().connectCellSer();
		}
                else if(command == commands[7]) {
			MapDrawer.getMidlet().stopCellSer();
		}
                else if(command == commands[8]) {
			MapDrawer.getMidlet().showInfoCellSer();
		}
	}

}
